<?php
/*
	获取活动详情
	电商客商品列表页和商品详情页会调用本方法以获得商品详情
*/
defined('BY_JYA') or exit('error');
list($goods_id,$mid)=$arguments;
$mid=$mid?:$_SESSION['uid'];
$actives=$this->get('active',array('goods_id'=>$goods_id,'stop'=>0,'start_time <'=>TIMESTAMP,'end_time >'=>TIMESTAMP));
if(!$actives['id']){
	return false;
}
$lognum=pdo_count('jy_giftbao_active_log',array('active_id'=>$actives['id'],'ispay'=>1,'mid'=>$mid,'uniacid'=>$_SESSION['uniacid']));
if($lognum>=$actives['num'] && $actives['num']){
	return false;
}
if($actives['start_time']<TIMESTAMP && $actives['end_time']>TIMESTAMP){
			$status=1;
			$rest_time=model('jy_weishop/model')->date($actives['end_time']-TIMESTAMP);
			$rest_time2=$actives['end_time'];
}
if($actives['start_time']>TIMESTAMP){
			$status=0;
			$rest_time=model('jy_weishop/model')->date($actives['start_time']-TIMESTAMP);
			$rest_time2=$actives['start_time'];
}
$rest_time=model('jy_weishop/model')->date($actives['end_time']-TIMESTAMP);
$start_time=model('jy_weishop/model')->date($actives['start_time']-TIMESTAMP);
$actives['status']=$status;
$actives['rest_time']=$rest_time;
$actives['rest_time2']=$rest_time2;
$actives['end_time']=date('Y-m-d H:i:s',$actives['end_time']);
$actives['start_time']=date('Y-m-d H:i:s',$actives['start_time']);
$actives['title']='送礼包';
$actives['libao_price']=$actives['price'];
$actives['price']=0;
$actives['libaos']=$actives['libaos']?json_decode($actives['libaos'],true):array();
if(empty($actives['libaos'])){
	return false;
}
foreach($actives['libaos'] as &$lb){
	$lb['price']=pdo_getcolumn('jy_giftbao_libao',array('id'=>$lb['id']),'price');
}
$actives['active_libaonum']=count($actives['libaos']);
$actives['active_choosenum']=$actives['choosenum'];
return $actives;